package com.hx.portal.controller.order;

import com.hx.common.result.PageResult;
import com.hx.common.result.Result;
import com.hx.order.pojo.Status;
import com.hx.order.service.StatusService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/status")
@Api(description = "订单状态")
public class StatusController {

    @Reference
    private StatusService statusService;
    @ApiOperation(value = "查询所有品牌",notes = "查询所有品牌",httpMethod = "GET")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功!"),
            @ApiResponse(code=500,message="服务器开小差了!")
    })
    @GetMapping("/findAll")
    public List<Status> findAll(){
        return statusService.findAll();
    }
    @ApiOperation(value = "查询所有品牌",notes = "查询所有品牌",httpMethod = "GET")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功!"),
            @ApiResponse(code=500,message="服务器开小差了!")
    })
    @GetMapping("/findPage")
    public PageResult<Status> findPage(int page, int size){
        return statusService.findPage(page, size);
    }
    @ApiOperation(value = "查询所有品牌",notes = "查询所有品牌",httpMethod = "POST")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功!"),
            @ApiResponse(code=500,message="服务器开小差了!")
    })
    @PostMapping("/findList")
    public List<Status> findList(@RequestBody Map<String,Object> searchMap){
        return statusService.findList(searchMap);
    }
    @ApiOperation(value = "查询所有品牌",notes = "查询所有品牌",httpMethod = "POST")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功!"),
            @ApiResponse(code=500,message="服务器开小差了!")
    })
    @PostMapping("/findPage")
    public PageResult<Status> findPage(@RequestBody Map<String,Object> searchMap,int page, int size){
        return  statusService.findPage(searchMap,page,size);
    }
    @ApiOperation(value = "查询所有品牌",notes = "查询所有品牌",httpMethod = "GET")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功!"),
            @ApiResponse(code=500,message="服务器开小差了!")
    })
    @GetMapping("/findById")
    public Status findById(String orderId){
        return statusService.findById(orderId);
    }

    @ApiOperation(value = "查询所有品牌",notes = "查询所有品牌",httpMethod = "POST")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功!"),
            @ApiResponse(code=500,message="服务器开小差了!")
    })
    @PostMapping("/add")
    public Result add(@RequestBody Status status){
        statusService.add(status);
        return new Result();
    }
    @ApiOperation(value = "查询所有品牌",notes = "查询所有品牌",httpMethod = "POST")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功!"),
            @ApiResponse(code=500,message="服务器开小差了!")
    })
    @PostMapping("/update")
    public Result update(@RequestBody Status status){
        statusService.update(status);
        return new Result();
    }
    @ApiOperation(value = "查询所有品牌",notes = "查询所有品牌",httpMethod = "GET")
    @ApiResponses({
            @ApiResponse(code=200,message="请求成功!"),
            @ApiResponse(code=500,message="服务器开小差了!")
    })
    @GetMapping("/delete")
    public Result delete(String orderId){
        statusService.delete(orderId);
        return new Result();
    }

}
